package cn.com.zpark.servlet_request;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @PackageName: cn.com.zpark.servlet_request
 * @ClassName: ServletRequestDemo01
 * @Description:
 * @author: RZS
 * @date: 2021/11/13  15:06
 */
@WebServlet("/srd1.do")
public class ServletRequestDemo01 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        /**
         * 获取请求行的内容
         */
        String method = request.getMethod();
        String uri = request.getRequestURI();
        String queryString = request.getQueryString();
        String path = request.getContextPath();
        String servletPath = request.getServletPath();
        String addr = request.getRemoteAddr();
        String host = request.getRemoteHost();

        System.out.println(method);
        System.out.println(uri);
        System.out.println(queryString);
        System.out.println(path);
        System.out.println(servletPath);
        System.out.println(addr);
        System.out.println(host);
    }
}
